import React, { useState } from 'react';
import { useRequest } from 'umi';

const Demo_useRequest = () => {
  const [num, setNum] = useState(0);
  console.log(dock);
  function getUsername() {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          data: {
            name: 'Ax',
          },
        });
      }, 1000);
    });
  }

  const { run } = useRequest(getUsername, {
    manual: true,
  });
  const handlerClick = () => {
    setNum((origin) => origin + 1);
    console.log(run());
  };
  return (
    <div>
      <button onClick={handlerClick}> setNum - {num} </button>
    </div>
  );
};

export default Demo_useRequest;
